#include "UnitGroupManager.h"

namespace BroodWar
{
	namespace Addon
	{
		UnitGroupManager::UnitGroupManager()
		{
			instance = BWSAL::UnitGroupManager::create();
		}

		UnitGroupManager::~UnitGroupManager()
		{
			BWSAL::UnitGroupManager::destroy();
		}

		UnitGroupManager::!UnitGroupManager()
		{
			BWSAL::UnitGroupManager::destroy();
		}

		UnitGroupManager^ UnitGroupManager::Instance::get()
		{
			if(s_instance == nullptr)
				s_instance = gcnew UnitGroupManager();
			return s_instance;
		}

		void UnitGroupManager::OnUnitDiscover(Unit^ unit)
		{
			return instance->onUnitDiscover(ConvertUnit(unit));
		}
		
		void UnitGroupManager::OnUnitEvade(Unit^ unit)
		{
			return instance->onUnitEvade(ConvertUnit(unit));
		}
		
		void UnitGroupManager::OnUnitMorph(Unit^ unit)
		{
			return instance->onUnitMorph(ConvertUnit(unit));
		}
		
		void UnitGroupManager::OnUnitRenegade(Unit^ unit)
		{
			return instance->onUnitRenegade(ConvertUnit(unit));
		}

		UnitGroup^ UnitGroupManager::AllUnits::get()
		{
			return ConvertUnitGroup(BWSAL::AllUnits());
		}
		
		UnitGroup^ UnitGroupManager::SelectAll()
		{
			return ConvertUnitGroup(BWSAL::SelectAll());
		}
		
		UnitGroup^ UnitGroupManager::SelectAll(Api::Enum::UnitType type)
		{
			return ConvertUnitGroup(BWSAL::SelectAll(ConvertUnitType(type)));
		}
		
		UnitGroup^ UnitGroupManager::SelectAllEnemy()
		{
			return ConvertUnitGroup(BWSAL::SelectAllEnemy());
		}
		
		UnitGroup^ UnitGroupManager::SelectAllEnemy(Api::Enum::UnitType type)
		{
			return ConvertUnitGroup(BWSAL::SelectAllEnemy(ConvertUnitType(type)));
		}
		
		UnitGroup^ UnitGroupManager::SelectAll(Player^ player, Api::Enum::UnitType type)
		{
			return ConvertUnitGroup(BWSAL::SelectAll(ConvertPlayer(player), ConvertUnitType(type)));
		}
	}
}
